package com.luckyframe.project.jmeter.execution;

import org.apache.jmeter.report.core.Sample;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ResultDataHolder {

    //planId ==> sample list
    private static Map<Long, List<Sample>> planSamples=new ConcurrentHashMap<>();


    public static List<Sample> getByPlanId(Long planId){
        return planSamples.get(planId);
    }

    public static  void addSample(Long planId,Sample sample){
        List<Sample> samples = getByPlanId(planId);
        if(samples==null){
            samples=new ArrayList<>();
        }

        samples.add(sample);
        planSamples.put(planId,samples);
    }


    public static  void put(Long planId,List<Sample> samples){
        planSamples.put(planId,samples);
    }

    public static void clear(Long planId){
        if(planSamples.containsKey(planId)){
            planSamples.remove(planId);
        }
    }

}
